// -----------------------------
// Author: 		Dhaenens Gert	
// Creation: 	9/19/2014 9:37:39 PM				
// -----------------------------

#include "Actor.h"

Actor::Actor(const TString& Name, const UInt32 Flags)
	: m_Name(Name)
	, m_Flags(Flags)
	, m_bEnabled(true)
{
}

Actor::~Actor()
{
}

void Actor::Update(Application* lpApp, Float deltaTime)
{
}

Bool Actor::HasFlags(UInt32 flags) const
{
	return ((m_Flags & flags) > 0);
}
void Actor::SetPosition(const Vector3& pos)
{
	m_Position = pos;
}
void Actor::SetRotation(const Matrix& rot)
{
	m_Rotation = rot;
}
void Actor::SetScale(const Matrix& scale)
{
	m_Scale = scale;
}
void Actor::SetEnabled(Bool bEnabled)
{
	m_bEnabled = bEnabled;
}
void Actor::SetLookAt(const Vector3& LookAt)
{
	Vector3 dir = (LookAt - m_Position).Normalized();
	m_Rotation.z = Vector4(dir, 0.0f).Normalized();
	m_Rotation.x = m_Rotation.z.CrossProduct(Vector4::UnitY).Normalized();
	m_Rotation.y = m_Rotation.z.CrossProduct(m_Rotation.x).Normalized();

	m_Rotation.t = Vector4(0.0f, 0.0f, 0.0F, 1.0f);
}

const TString& Actor::GetName() const
{
	return m_Name;
}

Vector3 Actor::GetPosition() const
{
	return m_Position;
}
Matrix Actor::GetRotation() const
{
	return m_Rotation;
}
Matrix Actor::GetScale() const
{
	return m_Scale;
}
Matrix Actor::GetWorld() const
{
	return (m_Scale * m_Rotation * Matrix::Translation(m_Position));
}
Bool Actor::GetEnabled() const
{
	return m_bEnabled;
}

Vector3 Actor::GetForward() const
{
	return m_Rotation.z.Normalized();
}
Vector3 Actor::GetRight() const
{
	return m_Rotation.x.Normalized();
}
Vector3 Actor::GetUp() const
{
	return m_Rotation.y.Normalized();
}